package com.golang.api.redis;

import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.TimeUnit;

@Component
public class TokenService {

	@Autowired
	RedisCache redisCache;

	public int tokenTime=3;
			
	public TimeUnit timeUnit=TimeUnit.HOURS;
	
	/**
	 * 判断redis有没有
	 * 如果有 直接更新
	 * 没有 生成存进去
	 * */
	public String createToken(String userId) {
		String token=UUID.randomUUID().toString();
		redisCache.setCacheString(token, userId, tokenTime, timeUnit);
        return token;
    }
	
}
